package com.ruoyi.web.controller.laiqianba.merchant;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.DataMatchOrderItem;
import com.ruoyi.merchant.service.IDataMatchOrderItemService;
import com.ruoyi.web.wrapper.DataMatchOrderItemWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 商户匹配订单子项信息Controller
 * 
 * @author ruoyi
 * @date 2023-10-26
 */
@RestController
@RequestMapping("/merchant/orderItemInfo")
public class DataMatchOrderItemController extends BaseController
{
    @Autowired
    private IDataMatchOrderItemService dataMatchOrderItemService;

    /**
     * 查询商户匹配订单子项信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataMatchOrderItem dataMatchOrderItem)
    {
        startPage();
        List<Map<String, Object>> list = dataMatchOrderItemService.selectDataMatchOrderItemMapList(dataMatchOrderItem);
        list = new DataMatchOrderItemWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户匹配订单子项信息列表
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:export')")
    @Log(title = "商户匹配订单子项信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataMatchOrderItem dataMatchOrderItem)
    {
        List<DataMatchOrderItem> list = dataMatchOrderItemService.selectDataMatchOrderItemList(dataMatchOrderItem);
        ExcelUtil<DataMatchOrderItem> util = new ExcelUtil<DataMatchOrderItem>(DataMatchOrderItem.class);
        util.exportExcel(response, list, "商户匹配订单子项信息数据");
    }

    /**
     * 获取商户匹配订单子项信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(dataMatchOrderItemService.selectDataMatchOrderItemById(id));
    }

    /**
     * 新增商户匹配订单子项信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:add')")
    @Log(title = "商户匹配订单子项信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataMatchOrderItem dataMatchOrderItem)
    {
        return toAjax(dataMatchOrderItemService.insertDataMatchOrderItem(dataMatchOrderItem));
    }

    /**
     * 修改商户匹配订单子项信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:edit')")
    @Log(title = "商户匹配订单子项信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataMatchOrderItem dataMatchOrderItem)
    {
        return toAjax(dataMatchOrderItemService.updateDataMatchOrderItem(dataMatchOrderItem));
    }

    /**
     * 删除商户匹配订单子项信息
     */
    @PreAuthorize("@ss.hasPermi('merchant:orderItemInfo:remove')")
    @Log(title = "商户匹配订单子项信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dataMatchOrderItemService.deleteDataMatchOrderItemByIds(ids));
    }
}
